package com.whmskj.xjlhbc.service.impl;
import com.whmskj.xjlhbc.core.AjaxResult;
import com.whmskj.xjlhbc.core.Page;
import com.whmskj.xjlhbc.dto.warehouse.Bzwrb;
import com.whmskj.xjlhbc.dto.warehouse.Cprb;
import com.whmskj.xjlhbc.dto.warehouse.Ysrb;
import com.whmskj.xjlhbc.mapper.WarehouseDailyReportMapper;
import com.whmskj.xjlhbc.service.WarehouseDailyReportService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Author: Sakura
 * @Date: 2025/8/20 15:57
 * @Version: v1.0.0
 * @Description: TODO
 **/

@Service
@Slf4j
public class WarehouseDailyReportServiceImpl  implements WarehouseDailyReportService {

    @Autowired
    private WarehouseDailyReportMapper Mapper;

    @Override
    public AjaxResult getYsrbList( String keyword) {
        Page.startPage();
        // 获取最新日期的数据
        String latestDate = Mapper.selectLatestYsrbDate();
        List<Ysrb> list = Mapper.selectYsrbList(latestDate,keyword);
        return Page.getDataTable(list);
    }

    @Override
    public AjaxResult getBzwrbList(String keyword) {
        Page.startPage();
        // 获取最新日期的数据
        String latestDate = Mapper.selectLatestBzwrbDate();
        List<Bzwrb> list = Mapper.selectBzwrbList(latestDate, keyword);
        return Page.getDataTable(list);
    }

    @Override
    public AjaxResult getCprbList(String keyword) {
            Page.startPage();
            // 获取最新日期的数据
            String latestDate = Mapper.selectLatestCprbDate();
            List<Cprb> list = Mapper.selectCprbList(latestDate, keyword);
            return Page.getDataTable(list);
    }

    @Override
    public AjaxResult quickSearch(String date, String keyword) {
        try {
            Map<String, Object> result = new HashMap<>();
            return AjaxResult.success(result);
        } catch (Exception e) {
            return AjaxResult.error("快捷筛选查询失败");
        }
    }

}
